home *** CD-ROM | disk | FTP | other *** search
/ AppleScript - The Beta Release / AppleScript - The Beta Release.iso / Documentation / develop / Apple Event Objects and You / Apple Event Objects (code) / ScriptScrap.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-08  |  4.8 KB  |  123 lines  |  [TEXT/KAHL]

  1. /* File: ScriptScrap.h */
  2.  
  3. /* ========================== Window & Menu Constants ============================= */
  4.  
  5. #define    kAppleMenu    1001
  6. enum    {
  7.             cAbout = 1
  8.         };
  9.  
  10. #define    kFileMenu    1002
  11. enum    {
  12.             cNew = 1,
  13.             cOpen,
  14.             cClose,
  15.             /* --- */
  16.             cQuit = 5
  17.         };
  18.  
  19. #define    kEditMenu    1003
  20.  
  21. /* Constants for windows and dialogs */
  22. #define    kDisplayWindow    1001
  23. #define    kAboutDialog    1001
  24.  
  25. /* ========================== Window Information ============================= */
  26.  
  27. /* Each window has a copy of the following structure (stored in a relocatable block) */
  28. /* attached through the window's refCon. It contains basic information used to keep  */
  29. /* the window's display current.                                                     */
  30.  
  31. typedef struct {
  32.             FSSpec          fileSpec;                /* The FSSpec for our file */
  33.             short          fRefNum;                /* 0 if the file's not open, otherwise the refNum */
  34.                                                 /* of the resource fork */
  35.             ControlHandle selectionBar;            /* the scroll bar which determines which item is */
  36.                                                 /* displayed */
  37.             short          numEntries,            /* How many entries do we have? */
  38.                           currEntryNum;            /* Which entry is being displayed? */
  39.             ResType          currEntryType;        /* What type should we use for the display? */
  40.             Rect          drawingArea;            /* This is where the image is drawn */
  41.             Rect          statusArea;            /* The area at the bottom which lists the number */
  42.                                                 /* and types of items in this entry */
  43.         } WindowInfo, *wiPtr, **wiHand;
  44.  
  45.  
  46. /* ========================== Error Checking ============================= */
  47.  
  48. /* One of these values will be returned by the pointer and handle checking functions. */
  49. enum {kPointerOK = 0,
  50.       kPointerNULL,
  51.       kPointerOdd
  52.      };
  53.  
  54. /* If you pass in "kIsFatal" as an option to the error checking code, the code will */
  55. /* call ExitToShell() after reporting the error. */
  56. #ifndef kIsFatal
  57.     #define kIsFatal true
  58.     #define kNonFatal false
  59. #endif
  60.  
  61. /* ========================== Apple Event Object Classes ============================= */
  62.  
  63. /* Constants for the 2 new classes defined by this application */
  64. #define    cEntry    'NTRY'
  65. #define    cScrapItem    'ITEM'
  66.  
  67. /* ========================== Tokens ============================= */
  68.  
  69. /* Token type flags */
  70. #define    kObjectToken    0x0001
  71. #define    kPropToken        0x0002
  72.          
  73.  
  74. /* As mentioned in the article, you can combine multiple token definitions into one        */
  75. /* or more larger tokens. We've done that with the 5 object classes in our hierarchy    */
  76. /* (application, document/window, entry, and item) and have come up with the structure    */
  77. /* below.                                                                                 */
  78. struct ourToken {
  79.      DescType    dispatchClass;        /* If this token represents an object, then this */
  80.                                      /* is the object's class. If this token represents */
  81.                                      /* a property, then this is the class of the object */
  82.                                      /* containing the property.                            */
  83.      short        flags;                /* A set of bit flags, defined above */
  84.      long        objectIndex;        /* Our position within the container */
  85.      DescType    propertyCode;        /* If the user wants a property, this tells which one */
  86.      WindowPtr    docWindow;            /* The window containing this document (if any) */
  87.      FSSpec        fileSpec;
  88.      short        fRefNum;            /* If this is a document (or some element of a document), here's the refNum */
  89.      short        resID;                /* If this is an item, what is the resource ID number? */
  90.      ResType    itemType;            /* What type of item should we get from the entry */
  91. };
  92.  
  93. typedef struct ourToken ourToken, *tokenPtr, **tokenHand;
  94.  
  95. /* The following definitions make it easier to get at the fields of our token */
  96. #define    tokenDispatchClass(tokenDesc)     ((**(tokenHand)((tokenDesc).dataHandle)).dispatchClass)
  97. #define    tokenFlags(tokenDesc)            (**(tokenHand)((tokenDesc).dataHandle)).flags
  98. #define    tokenObjectIndex(tokenDesc)        (**(tokenHand)((tokenDesc).dataHandle)).objectIndex
  99. #define    tokenPropCode(tokenDesc)        (**(tokenHand)((tokenDesc).dataHandle)).propertyCode
  100. #define    tokenWindow(tokenDesc)             (**(tokenHand)((tokenDesc).dataHandle)).docWindow
  101. #define    tokenFileSpec(tokenDesc)         (**(tokenHand)((tokenDesc).dataHandle)).fileSpec
  102. #define    tokenFRefNum(tokenDesc)         (**(tokenHand)((tokenDesc).dataHandle)).fRefNum
  103. #define    tokenSlotNum(tokenDesc)         (**(tokenHand)((tokenDesc).dataHandle)).slotNum
  104. #define    tokenResID(tokenDesc)             (**(tokenHand)((tokenDesc).dataHandle)).resID
  105. #define    tokenItemType(tokenDesc)         (**(tokenHand)((tokenDesc).dataHandle)).itemType
  106.  
  107. /* ========================== Scrapbook data types ============================= */
  108.  
  109. typedef    unsigned char smap[256];    /* This is a "scrapbook map" -- See ScrapTools.c for more information */
  110. typedef smap **smapHand;
  111.  
  112. /* ========================== Global variables ============================= */
  113.  
  114. #ifdef __Main__
  115.     #define    global
  116. #else
  117.     #define    global    extern
  118. #endif
  119.  
  120. global    Boolean            gDone;              /*    quit program flag    */
  121. global    Boolean            gInFront;            /* Are we the frontmost application?? */
  122. global    AEAddressDesc     gSelfAddressDesc;    /* Used when sending Apple events bck to this app */
  123.